﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace FrontEnd
{
    public class MultiplierValueConverter : DependencyObject, IValueConverter
    {
        public bool Inverse
        {
            get { return (bool)GetValue(InverseProperty); }
            set { SetValue(InverseProperty, value); }
        }
        public static readonly DependencyProperty InverseProperty = DependencyProperty.Register("Inverse", typeof(bool), typeof(MultiplierValueConverter), new UIPropertyMetadata(false));

        public double Multiplier
        {
            get { return (double)GetValue(MultiplierProperty); }
            set { SetValue(MultiplierProperty, value); }
        }
        public static readonly DependencyProperty MultiplierProperty = DependencyProperty.Register("Multiplier", typeof(double), typeof(MultiplierValueConverter), new UIPropertyMetadata(1.0));

        public MultiplierValueConverter()
        {
        }
        public MultiplierValueConverter(double mult, bool inverse)
        {
            Multiplier = mult;
            Inverse = inverse;
        }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!Inverse)
                return Multiplier * (double)value;
            else
                return Multiplier / (double)value;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
